package com.itheima.Test;

import com.itheima.domain.Student;

import java.util.ArrayList;
import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Student stu1 = getStudent(1);
        Student stu2 = getStudent(2);
        Student stu3 = getStudent(3);

        list.add(stu1);
        list.add(stu2);
        list.add(stu3);

        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i).getName() + "..." + list.get(i).getAge());
        }

    }

    public static Student getStudent(int count) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入第" + count + "个学生姓名");
        String name = sc.next();
        System.out.println("请输入第" + count + "个学生年龄");
        int age = sc.nextInt();
        Student stu = new Student(name, age);
        return stu;
    }
}
